
package com.wallj.videolibrary.filters;

import android.content.Context;
import android.opengl.GLES30;

import com.wallj.videolibrary.player.WaterMarkEntity;
import com.wallj.videolibrary.utils.OpenGLUtils;

import java.nio.FloatBuffer;

/**
 * created by jw200 at 2019/3/26 20:11
 **/
public class SpWaterMarkFilter extends GLImageFilter {

    WaterMarkEntity entity;

    public SpWaterMarkFilter(Context context) {
        super(context, VERTEX_SHADER,
                OpenGLUtils.getShaderFromAssets(context, "shader/base/fragment_flip_y.glsl"));
    }

    public SpWaterMarkFilter(Context context, String vertexShader, String fragmentShader) {
        super(context, vertexShader, fragmentShader);
    }

    public void setWaterMark(WaterMarkEntity waterMark) {
        this.entity = waterMark;
    }

    @Override
    protected void onDrawTexture(int textureId, FloatBuffer vertexBuffer,
            FloatBuffer textureBuffer) {
        GLES30.glEnable(GLES30.GL_BLEND);
        GLES30.glBlendFunc(GLES30.GL_ONE, GLES30.GL_ONE_MINUS_SRC_ALPHA);
        super.onDrawTexture(textureId, vertexBuffer, textureBuffer);
        GLES30.glDisable(GLES30.GL_BLEND);
    }
}
